package cn.edu.just.firstjavaapp.l19;

import java.util.*;

public class MapBasic {
    public static void main(String[] args) {
        Map<String,String> contacks = new TreeMap<>();
        contacks.put("张三","13011223344");
        contacks.put("李四","18900112233");
        contacks.put("王武","13389765678");
        contacks.put("钱七","186");
        System.out.println(contacks);
        System.out.println(contacks.get("李四"));  //根据key找value
        System.out.println(contacks.get("赵六")); //找不到，返回null
        System.out.println(contacks.containsKey("李四"));  //返回true
        System.out.println(contacks.containsValue("18900112233"));
        System.out.println(contacks.size());
        System.out.println(contacks.isEmpty());
        System.out.println(contacks.get(null));  //null也可以是Key
        Set<String> names = contacks.keySet();    //key的集合
        System.out.println(names);
        Collection<String> numbers= contacks.values(); //value的集合
        System.out.println(numbers);
        Set<Map.Entry<String,String>> entry= contacks.entrySet();//键值对的集合
        System.out.println(entry);
    }
}
